home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / stat_.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.6 KB  |  93 lines

  1. /* Copyright (C) 1991, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: stat_.h,v 1.5 2000/09/19 19:00:51 lpd Exp $ */
  20. /* Generic substitute for Unix sys/stat.h */
  21.  
  22. #ifndef stat__INCLUDED
  23. #  define stat__INCLUDED
  24.  
  25. /* We must include std.h before any file that includes sys/types.h. */
  26. #include "std.h"
  27. #include <sys/stat.h>
  28.  
  29. /*
  30.  * Many environments, including the MS-DOS compilers, don't define
  31.  * the st_blocks member of a stat structure.
  32.  */
  33. #if defined(__SVR3) || defined(__EMX__) || defined(__DVX__) || defined(OSK) || defined(__MSDOS__) || defined(__QNX__) || defined(VMS) || defined(__WIN32__) || defined(__IBMC__) || defined(__BEOS__) || defined(Plan9) || defined(__WATCOMC__)
  34. #  define stat_blocks(psbuf) (((psbuf)->st_size + 1023) >> 10)
  35. #else
  36. #  define stat_blocks(psbuf) ((psbuf)->st_blocks)
  37. #endif
  38.  
  39. /*
  40.  * Microsoft C uses _stat instead of stat,
  41.  * for both the function name and the structure name.
  42.  */
  43. #ifdef _MSC_VER
  44. #  define stat _stat
  45. #endif
  46.  
  47. /*
  48.  * Some (System V?) systems test for directories in a slightly different way.
  49.  */
  50. #if defined(OSK) || !defined(S_ISDIR)
  51. #  define stat_is_dir(stbuf) ((stbuf).st_mode & S_IFDIR)
  52. #else
  53. #  define stat_is_dir(stbuf) S_ISDIR((stbuf).st_mode)
  54. #endif
  55.  
  56. /*
  57.  * Some systems have S_IFMT and S_IFCHR but not S_ISCHR.
  58.  */
  59. #ifndef S_ISCHR
  60. #  ifndef S_IFMT
  61. #    ifdef _S_IFMT
  62. #      define S_IFMT _S_IFMT
  63. #      define S_IFCHR _S_IFCHR
  64. #    else
  65. #    ifdef __S_IFMT
  66. #      define S_IFMT __S_IFMT
  67. #      define S_IFCHR __S_IFCHR
  68. #    endif
  69. #    endif
  70. #  endif
  71. #  define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
  72. #endif
  73.  
  74. /*
  75.  * Microsoft C doesn't define S_IRUSR or S_IWUSR.
  76.  */
  77. #ifndef S_IRUSR
  78. #  ifndef S_IREAD
  79. #    define S_IRUSR _S_IREAD
  80. #  else
  81. #    define S_IRUSR S_IREAD
  82. #  endif
  83. #endif
  84. #ifndef S_IWUSR
  85. #  ifndef S_IWRITE
  86. #    define S_IWUSR _S_IWRITE
  87. #  else
  88. #    define S_IWUSR S_IWRITE
  89. #  endif
  90. #endif
  91.  
  92. #endif /* stat__INCLUDED */
  93.